package com.guanyong.dao;

import com.guanyong.model.VideoSourceModel;
import org.apache.ibatis.annotations.Param;
import org.apache.ibatis.annotations.ResultMap;
import org.apache.ibatis.annotations.Select;

import java.util.List;

/**
 * Created by mxk on 2017/6/2.
 */

public interface IVideoSourceDaoMapper {

    @Select("SELECT * FROM t_ad_videosource  where f_id=#{fId}")
    @ResultMap("VideoSourceResultMap")
    VideoSourceModel selectByPrimaryKey(Integer fId);

    @Select("SELECT * FROM t_ad_videosource  where f_classtype=#{classtype} and f_objectid=#{objectid}")
    @ResultMap("VideoSourceResultMap")
    List<VideoSourceModel> selectVideoScorceAll(@Param("objectid") String objectid,
                                                @Param("classtype") Integer classtype);

    @Select("SELECT * FROM t_ad_videosource  where f_classtype=#{classtype} and f_objectid=#{objectid} and f_show=#{show}")
    @ResultMap("VideoSourceResultMap")
    List<VideoSourceModel> selectVideoScorce(@Param("objectid") String objectid,
                                             @Param("classtype") Integer classtype,
                                             @Param("show") Integer show);

    @Select("SELECT * FROM t_ad_videosource  where f_classtype=#{classtype} and f_objectid=#{objectid} and f_show=0 and f_sourcetype=#{fSourcetype} LIMIT 1")
    @ResultMap("VideoSourceResultMap")
    VideoSourceModel selectVideoScorceByType(@Param("objectid") String objectid,
                                             @Param("classtype") Integer classtype,
                                             @Param("fSourcetype") Integer fSourcetype);

    @Select("SELECT * FROM t_ad_videosource  where f_objectid=#{objectid} and f_show=#{show} and f_sourcetype = #{sourceType} LIMIT  1")
    @ResultMap("VideoSourceResultMap")
    VideoSourceModel getVideoScorce(@Param("objectid") String objectid,
                                    @Param("sourceType") Integer sourceType,
                                             @Param("show") Integer show);

    int update(@Param(value = "record") VideoSourceModel record);
    int insert(@Param(value = "record") VideoSourceModel record);


    Integer SelectVideoSourceListCount(@Param("sourceType")Integer sourceType);

    List<VideoSourceModel> SelectVideoSourceList(@Param("sourceType")Integer sourceTypeClips,
                                                 @Param("offset") Integer offset,
                                                 @Param("limit") Integer limit);
}
